# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=py3-cmsis-pack-manager
pkgver=0.5.3
pkgrel=2
pkgdesc="Python manager for CMSIS-Pack index and cache with fast Rust backend"
url="https://github.com/pyocd/cmsis-pack-manager"
# s390x, ppc64le and riscv64 blocked by ring crate
arch="all !s390x !ppc64le !riscv64"
license="Apache-2.0"
depends="
	py3-appdirs
	py3-cffi
	py3-yaml
	"
makedepends="
	cargo
	py3-gpep517
	py3-installer
	py3-maturin
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-jinja2
	py3-pytest
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver-1.tar.gz::https://github.com/pyocd/cmsis-pack-manager/archive/refs/tags/v$pkgver.tar.gz"
# Required to download Rust crates
options="net"
builddir="$srcdir/cmsis-pack-manager-$pkgver"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--config-json '{"build-args": "--frozen"}' \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	cd .testenv
	bin/python3 -m pytest --import-mode=importlib ..
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
50e297c2920ea6d6c716429e7b50f8fd5589c1db868de6fee9b84bb09b0829b11a786d34710e9b52d3e5fc85f2363d50c6a141f060771ce683f53030995add43  py3-cmsis-pack-manager-0.5.3-1.tar.gz
"
